package com.mt.course.service.impl;

import java.util.List;
import java.util.Map;


import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;

import com.mt.common.PagerInfo;
import com.mt.common.ServiceResult;
import com.mt.common.constants.BaseErrorConstants;
import com.mt.course.api.service.ICourseGoodsLearnTimeLogService;
import com.mt.course.entity.CourseGoodsLearnTimeLogEntity;
import com.mt.course.service.model.CourseGoodsLearnTimeLogServiceModel;
import org.springframework.stereotype.Service;

@Service
public class CourseGoodsLearnTimeLogServiceImpl implements ICourseGoodsLearnTimeLogService {
    private static final org.slf4j.Logger LOGGER = LoggerFactory.getLogger(CourseGoodsLearnTimeLogServiceImpl.class);

    @Autowired
    private CourseGoodsLearnTimeLogServiceModel courseGoodsLearnTimeLogServiceModel;

    public ServiceResult<CourseGoodsLearnTimeLogEntity> findInfo(Map<String, Object> params) {
        ServiceResult<CourseGoodsLearnTimeLogEntity> result = null;
        try {
            result = courseGoodsLearnTimeLogServiceModel.selectInfo(params);
        } catch (Exception e) {
            LOGGER.error("[CourseGoodsLearnLogServiceImpl][findInfo]：query findInfo occur exception", e);
            result.setError(BaseErrorConstants.ERROR_CODE_SERVICE_CONTROLLER, "查询详情错误");
        }
        return result;
    }

    public ServiceResult<List<CourseGoodsLearnTimeLogEntity>> findList(Map<String, Object> params,
            PagerInfo<?> pagerInfo) {
        ServiceResult<List<CourseGoodsLearnTimeLogEntity>>
            result = new ServiceResult<List<CourseGoodsLearnTimeLogEntity>>();
        try {
            result = courseGoodsLearnTimeLogServiceModel.selectList(params, pagerInfo);
        } catch (Exception e) {
            LOGGER.error("[CourseGoodsLearnLogServiceImpl][findList]：query findList occur exception", e);
            result.setError(BaseErrorConstants.ERROR_CODE_SERVICE_CONTROLLER, "查询列表错误");
        }
        return result;
    }

    public ServiceResult<Integer> doInsert(CourseGoodsLearnTimeLogEntity courseGoodsLearnTimeLogEntity) {
        ServiceResult<Integer> result = new ServiceResult<Integer>();
        try {
            result = courseGoodsLearnTimeLogServiceModel.insert(courseGoodsLearnTimeLogEntity);
        } catch (Exception e) {
            LOGGER.error("[CourseGoodsLearnLogServiceImpl][doInsert]：query doInsert occur exception", e);
            result.setError(BaseErrorConstants.ERROR_CODE_SERVICE_CONTROLLER, "创建信息错误");
        }
        return result;
    }

    public ServiceResult<Integer> doUpdate(CourseGoodsLearnTimeLogEntity courseGoodsLearnTimeLogEntity) {
        ServiceResult<Integer> result = new ServiceResult<Integer>();
        try {
            result = courseGoodsLearnTimeLogServiceModel.updateRelate(courseGoodsLearnTimeLogEntity);
        } catch (Exception e) {
            LOGGER.error("[CourseGoodsLearnLogServiceImpl][doUpdate]：query doUpdate occur exception", e);
            result.setError(BaseErrorConstants.ERROR_CODE_SERVICE_CONTROLLER, "编辑信息错误");
        }
        return result;
    }

    public ServiceResult<Integer> doDeleteById(Integer courseGoodsLearnLogId) {
        ServiceResult<Integer> result = new ServiceResult<Integer>();
        try {
            result = courseGoodsLearnTimeLogServiceModel.deleteByPrimaryKey(courseGoodsLearnLogId);
        } catch (Exception e) {
            LOGGER.error("[CourseGoodsLearnLogServiceImpl][doDeleteById]：query doDeleteById occur exception", e);
            result.setError(BaseErrorConstants.ERROR_CODE_SERVICE_CONTROLLER, "删除信息错误");
        }
        return result;
    }
}
